﻿<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>生产计划</title>
    <meta name="renderer" content=padding>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/commonjs.js"></script>
    <script src="~/js/layui/layui.js"></script>
    <script src="~/js/sysweb/planjs.js"></script>

</head>
<body>
    <div class="layui-fluid">
        <div id="bDiv">
            <ul lay-bar="disabled" class="mWebBanner">
             
                <li class="layui-nav-item" style="float:left;margin-left:1%">
                    <button id="btn-update" type="button" lay-filter="sreach" onclick="loadData()" class="buttonCss">
                        <i class="layui-icon" style="margin-right:3px">&#xe615;</i> 查 询
                    </button>
                </li>
                <li class="layui-nav-item" style="float:left;margin-left:3%">
                    <button id="btn-update" type="button" lay-filter="confirm" onclick="sureChoose()" class="buttonCss">
                        <i class="layui-icon" style="margin-right:3px">&#x1005;</i>确认选择
                    </button>
                </li>
                <li class="layui-nav-item" style="float:left;margin-left:3%">
                    <button id="btn-sync" type="button" onclick="closeWin()" class="buttonCss">
                        <i class="layui-icon" style="margin-right:3px">&#x1007;</i> 关闭页面
                    </button>
                </li>
            </ul>
        </div>
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body" style="margin-top:5px">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="plCode" placeholder="计划编码" autocomplete="off" class="layui-input" id="plCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="erpOrder" placeholder="订单编码" autocomplete="off" class="layui-input" id="erpOrder">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proCode" placeholder="存货编码" autocomplete="off" class="layui-input" id="proCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proName" placeholder="存货名称" autocomplete="off" class="layui-input" id="proName">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="cuName" placeholder="客户名称" autocomplete="off" class="layui-input" id="cuName">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="开始日期" name="sDate" id="sDate" style="margin-right:15px;">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="结束日期" name="eDate" id="eDate" style="margin-right:15px;">
                            </div>
                        </form>
                    </div>

                    <div class="layui-card-body layui-table-body layui-table-main" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>
<script>
    var list = new Array();
    var proCode="",proName="",cuCode="",cuName="";
    $(function () {
        proCode = getUrlVariable("proCode");
        cuCode = getUrlVariable("cuCode");
        cuName = getUrlVariable("cuName");
        proName = getUrlVariable("proName");
        $("input[ name='sDate']").val(getDate(-5));
        $("input[ name='eDate']").val(getDate(0));  
        $("input[ name='proCode']").val(proCode);
        $("input[ name='cuCode']").val(cuCode);
        $("input[ name='cuName']").val(cuName);
        $("input[ name='proName']").val(proName);

        loadData();
    })
    


    var dUrl = "../Plan/getDataList?dataType=RecentPlan&condition=";
    /**
     * 加载数据
     * **/
    function loadData(){

        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            if (conditon.includes("#")) {
                conditon = conditon.replace(/\#/g, "%23");
            }
            table.render({
                elem: '#list'
                , height: 'full-200'   //固定高度-即固定表头固定第一行首行
                , cols: [[ //标题栏
                    { type: 'checkbox' },
                    {field: 'plCode', align: 'center', title: '计划编码', width: 120, sort: true }
                    , { field: 'erpOrder', align: 'center', title: '销售订单号', width: 120, sort: true }
                    , { field: 'proCode', align: 'center', title: '存货编码', width: 100 }
                    , { field: 'proName', align: 'center', title: '存货名称', width: 110 }
                    , { field: 'spec', align: 'center', title: '规格', width: 100 }
                    , { field: 'number', align: 'center', title: '生产数量', width: 100 }
                    , { field: 'cuName', align: 'center', title: '关联客户', width: 120 }
                    // , { field: 'gyName', align: 'center', title: '生产工艺', width: 120 }
                    , { field: 'memo', align: 'center', title: '备注', width: 110 }
                    , { field: 'plTypeName', align: 'center', title: '计划类型', width: 90 }
                    , { field: 'createtime', align: 'center', title: '创建时间', width: 120, sort: true }
                ]], done: function (res, curr, count) {
                    // $("[data-field='id']").css('display', 'none');//隐藏列
                    currPage = curr;
                   
                }
                , url: dUrl + conditon
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [20, 25, 30]
                , limit: 20 //每页默认显示的数量
                , id: "list"
            });
           
            //监听工具条
            table.on('checkbox(list)', function (obj) {
              var checkStatus = table.checkStatus('list');
                var select = new Array();
                for (var i = 0; i < checkStatus.data.length; i++) {
                    select.push(checkStatus.data[i]);

                }
                cData = select;

            });


        });

    }

    layui.use(['laydate'], function () {
        var $ = layui.$;
        var laydate = layui.laydate;
        var nowTime = new Date().valueOf();
        var max = null;
        var start = laydate.render({
            elem: '#sDate',
            trigger: 'click',
            type: 'date',
            format: 'yyyy-MM-dd',
            max: nowTime,
            btns: ['clear', 'confirm'],
            done: function (value, date) {
                endMax = end.config.max;
                end.config.min = date; //最大时间为结束时间的开始值
                end.config.min.month = date.month - 1;
            }
        });
        var end = laydate.render({
            elem: '#eDate',
            trigger: 'click',
            type: 'date',
            max: 4073558400000,
            format: 'yyyy-MM-dd',
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = { 'date': curDate.getDate(), 'month': curDate.getMonth() + 1, 'year': curDate.getFullYear() };
                }
                start.config.max = date;//最小时间为开始时间的最大值
                start.config.max.month = date.month - 1;
            }
        })
    })
    var cData = new Array();
    /*
     *确认选择
        */
    function sureChoose() {
        if (cData.length < 1) {
            layer.msg("您没有选择任何计划", {icon:2}); return;
        } else {
            if (cData.length > 1) {
                layer.msg("请选择一条数据", { icon: 2 }); return;
            } else {
                parent.lastPlanPar(cData); //这是父页面函数
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        }
    }

</script>
